				<div class="section">
                	<script type="text/javascript">
					$(document).ready(function(){
						var $obj 	= $("#selectship");
						var $show 	= $("#room_show");
						var $ship   = $("#show_ship");
						var $ship_name = $("#ship_name");
						$obj.change(function(){
							$val = $(this).val();
							if($val == 0){
								alert("Please select a cruise!");
							}else{
								$.ajax({
									"url" 	: "<?php echo base_url(); ?>admin/checkrate/getrooms",
									"type"  : "post",
									"data"  : "val="+$val,
									"async" : false,
									success : function(result){
										$ship.html(result);
									}
								});
							}
						});
					});
					</script>
					<!--[if !IE]>start title wrapper<![endif]-->
					<div class="title_wrapper">
						<span class="title_wrapper_top"></span>
						<div class="title_wrapper_inner">
							<span class="title_wrapper_middle"></span>
							<div class="title_wrapper_content">
								<h2 class="menu_title">Manager tickets</h2>
							</div>
						</div>
						<span class="title_wrapper_bottom"></span>
					</div>
					<!--[if !IE]>end title wrapper<![endif]-->
					
					<!--[if !IE]>start section content<![endif]-->
					<div class="section_content">
						<span class="section_content_top"></span>
						
						<div class="section_content_inner">
                        	<div class="table_tabs_menu">
							<!--[if !IE]>start  tabs<![endif]-->
							<!--[if !IE]>end  tabs<![endif]-->

							</div>
				<!--[if !IE]>start table_wrapper<![endif]-->
							<div class="table_wrapper" style="background:none;">
								<div class="table_wrapper_inner" style="min-height:300px">
                                	<style>
										input{
											width:55px;
										}
									</style>
									<div id="box">
                                    <form method="post">
                                   	Select train<select name="trainid" id="trainid">
                                        <option value="0">Select a train</option>
                                        <?php
                                        foreach($listtrain as $items){
                                            echo "<option value='".$items['train_id']."'>".$items['train_name']."</option>";
                                        }
                                        ?>
                                    </select>
									<div style="margin:5px 0px">
                                    <div id="show_ship" style="margin-bottom:5px">
                                    </div></div>
									Type ticket <select name="ticktype">
										<option <?php if($ticktype==2) echo 'selected="selected"'; ?> value="2">Round trip</option>
										<option <?php if($ticktype==1) echo 'selected="selected"'; ?> value="1">One way</option>
									</select>
									
									From <input type="text" class="date" name="fromdate" /> To <input type="text" class="date" name="todate" />
									<input type="submit" name="ok" value="Go"/>-- OR -- <a  href="<?php echo base_url(); ?>admin/checkrate/addtick">Quick insert</a>
									</form>
									</div>
                                    <div id="loading" style="padding-bottom:5px;color:#F00;font-size:12px"></div>
									<table width="100%" id="haanh" border="1" style="border:solid #ccc 1px;" cellspacing="0">
									  <tr>
										<td width="14%">Day</td>
										<td width="14%">Number of ticket</td>
										<td width="13%">Departs</td>
										<td width="12%">Arrives</td>
										<td width="13%">Softseat</td>
										<td width="12%">Hardberth</td>
										<td width="11%">Softberth</td>
										<td width="11%">Vipberth</td>
									  </tr>
									   <?php 
										foreach($listdata as $k=>$v){
										?>
                                        <?php foreach($listdata[$k] as $value){ ?>
										<tr>
										<td><?php echo $k; ?></td>
										<td><input name="ticknum" type="text" onchange="update(this);" value="<?php echo $value["ticknum"];?>" size="10" datadate="<?php echo $k;?>" tickid="<?php echo $value["tickid"];?>" /></td>
										<td><input name="tickdeparts" type="text" onchange="update(this);" value="<?php echo $value["tickdeparts"];?>" size="10" datadate="<?php echo $k;?>" tickid="<?php echo $value["tickid"];?>" /></td>
										<td><input name="tickarrives" type="text" onchange="update(this);" value="<?php echo $value["tickarrives"];?>" size="10" datadate="<?php echo $k;?>" tickid="<?php echo $value["tickid"];?>" /></td>
										<td><input name="softseat" type="text" onchange="update(this);" value="<?php echo $value["softseat"];?>" size="10" datadate="<?php echo $k;?>" tickid="<?php echo $value["tickid"];?>" /></td>
										<td><input name="hardberth" type="text" onchange="update(this);" value="<?php echo $value["hardberth"];?>" size="10" datadate="<?php echo $k;?>" tickid="<?php echo $value["tickid"];?>" /></td>
										<td><input name="softberth" type="text" onchange="update(this);" value="<?php echo $value["softberth"];?>" size="10" datadate="<?php echo $k;?>" tickid="<?php echo $value["tickid"];?>" /></td>
										<td><input name="vipberth" type="text" onchange="update(this);" value="<?php echo $value["vipberth"];?>" size="10" datadate="<?php echo $k;?>" tickid="<?php echo $value["tickid"];?>" /></td>
									  </tr>
                                      <?php } } ?>
									 </table>
									<script type="text/javascript">
										$("#haanh td input").focus(function(){
											$("#loading").html("");
										});
										function update(inputelement){
											var value=$(inputelement).val();
											var datadate=$(inputelement).attr("datadate");
											var trainid="<?php echo $trainid; ?>";
											var type="<?php echo $ticktype; ?>";
											var field=$(inputelement).attr("name");
											var id = $(inputelement).attr("tickid");
											document.getElementById("loading").innerHTML = "<img src='<?php echo base_url(); ?>public/images/4-0.gif' />";
												$.post("<?php echo base_url(); ?>/admin/checkrate/updatefield",{field:field,data:value,date:datadate,id:id},function(dataresponse){
													document.getElementById("loading").innerHTML = "<img src='<?php echo base_url(); ?>public/images/active_icon.gif' width='19' style='float:left;margin:0px 5px 3px 0px;' />Updated...";
												});
										}
										$(document).ready(function (){
											$( ".date" ).datepicker({
											  changeMonth: true,
											  changeYear: true,
											  dateFormat:"yy-mm-dd"
											});
										});
									</script>
									</div>
                                </div>
							</div>
							<!--[if !IE]>end table_wrapper<![endif]-->
						</div>
						<span class="section_content_bottom"></span>
					</div>
					<!--[if !IE]>end section content<![endif]-->
				</div>